<template>
	<div>
		<el-dialog :title="$t('action.update')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_uid')" prop="uid">
							<el-input v-model="form.uid" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_uid')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_order')" prop="order">
							<el-input v-model="form.order" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_order')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_number')" prop="number">
							<el-input v-model="form.number" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_number')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_balance')" prop="balance">
							<el-input v-model="form.balance" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_balance')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_fee')" prop="fee">
							<el-input v-model="form.fee" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_fee')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_total')" prop="total">
							<el-input v-model="form.total" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_total')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
				   <el-col :span="24">
                        <el-form-item :label="$t('field.Withdraw_status')" prop="status">
                            <el-select style="width:100%" v-model="form.status" :size="size" clearable filterable :placeholder="$t('system.pleaseSelect')">
                                <el-option key="0"  label="提现申请" :value="0"></el-option>
                                <el-option key="1"  label="已批准" :value="1"></el-option>
                                <el-option key="2"  label="已取消" :value="2"></el-option>
                                <el-option key="3"  label="提现成功" :value="3"></el-option>
                                <el-option key="4"  label="已驳回" :value="4"></el-option>
                            </el-select>
                        </el-form-item>
                   </el-col>
				 </el-row>
	 	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_name')" prop="name">
							<el-input v-model="form.name" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_name')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_bank')" prop="bank">
							<el-input v-model="form.bank" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_bank')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_bank_address')" prop="bank_address">
							<el-input v-model="form.bank_address" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_bank_address')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_card')" prop="card">
							<el-input v-model="form.card" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_card')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_pay_time')" prop="pay_time">
							<el-date-picker type="date"   v-model="form.pay_time" clearable :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_pay_time')})"></el-date-picker>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_pay_order')" prop="pay_order">
							<el-input v-model="form.pay_order" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_pay_order')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_callback')" prop="callback">
							<el-input v-model="form.callback" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_callback')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_remark')" prop="remark">
							<el-input v-model="form.remark" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_remark')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_refer_to')" prop="refer_to">
							<el-input v-model="form.refer_to" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_refer_to')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_agent')" prop="agent">
							<el-input v-model="form.agent" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_agent')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_staff')" prop="staff">
							<el-input v-model="form.staff" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_staff')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_mother')" prop="mother">
							<el-input v-model="form.mother" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_mother')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_exchange')" prop="exchange">
							<el-input v-model="form.exchange" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_exchange')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_type')" prop="type">
							<el-input v-model="form.type" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_type')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_currency')" prop="currency">
							<el-select style="width:100%" v-model="form.currency" filterable clearable :placeholder="$t('system.pleaseSelect')">
								<el-option v-for="(item,i) in currencys" :key="i" :label="item.key" :value="item.val.toString()"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_to_amount')" prop="to_amount">
							<el-input v-model="form.to_amount" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_to_amount')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
				   <el-col :span="24">
                        <el-form-item :label="$t('field.Withdraw_withdraw_type')" prop="withdraw_type">
                            <el-select style="width:100%" v-model="form.withdraw_type" :size="size" clearable filterable :placeholder="$t('system.pleaseSelect')">
                                <el-option key="0"  label="银行卡" value="0"></el-option>
                                <el-option key="1"  label="数字货币" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                   </el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_wallet_address')" prop="wallet_address">
							<el-input v-model="form.wallet_address" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_wallet_address')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_bank_id')" prop="bank_id">
							<el-input v-model="form.bank_id" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_bank_id')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Withdraw_version')" prop="version">
							<el-input v-model="form.version" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Withdraw_version')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { update, getFieldList } from '@/api/app/withdraw'

export default {
	name:'withdrawupdate',
	components: {
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		info: {
			type: Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			form: {
			   uid:'',
			   order:'',
			   number:'',
			   balance:'',
			   fee:'',
			   total:'',
			   status:0,
			   create_time:'',
			   name:'',
			   bank:'',
			   bank_address:'',
			   card:'',
			   pay_time:'',
			   pay_order:'',
			   callback:'',
			   remark:'',
			   refer_to:'',
			   agent:'',
			   staff:'',
			   mother:'',
			   exchange:'',
			   type:'',
			   currency:'',
			   to_amount:'',
			   withdraw_type:0,
			   wallet_address:'',
			   bank_id:'',
			   version:'',
			},
			currencys:[],
		    initial:{},        
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
				getFieldList().then(res => {
					if(res.status == 200){
						this.currencys = res.data.currencys
					}
				})
			}
		}
	},
	methods: {
		open(){
			this.form = this.info
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					update(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss'
</style>
